<?php

namespace app\common\model;

use app\common\model\Base;


class Member extends Base {

    public function getGroupTextAttr($value, $data) {
        $status = model('member_group')->column('id,title');
        return isset($status[$data['group_id']]) ? $status[$data['group_id']] : '';
    }

    public function getStatusTextAttr($value, $data) {
        $status = [0 => '已冻结', 1 => ''];
        return isset($status[$data['status']]) ? $status[$data['status']] : 'NULL';
    }

    public function model_where($wheres = []) {
        
        
        // 框架分类
        if (request()->get('category'))
            $this->where('group_id', request()->get('category'));

        if (request()->get('sex'))
            $this->where('gender', request()->get('sex'));

        if (request()->get('keyword'))
            $this->where('nickname', 'like', '%' . request()->get('keyword') . '%');
        
        $this->order('id desc');

        return $this;
    }

}
